package com.claimSettlement.controller;

import com.claimSettlement.pojo.RiskType;
import com.claimSettlement.pojo.Warranty;
import com.claimSettlement.service.PolicyOpenFeginService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class PolicyController {
    @Resource
    PolicyOpenFeginService policyOpenFeginService;

    @RequestMapping("/risk/getRiskTypeBycaseId")
    public List<Integer> getRiskTypeBycaseId(String caseId,String type){
        return policyOpenFeginService.getRiskTypeBycaseId(caseId,type);
    }
    @RequestMapping("/risk/getRiskTypeAll")
    public List<RiskType> getRiskTypeAll(){
        return policyOpenFeginService.getRiskTypeAll();
    }

    @RequestMapping("/warranty/getWarrantyAll")
    public PageInfo<Warranty> getWarrantyAll(int page){
        return policyOpenFeginService.getWarrantyAll(page);
    }

    @RequestMapping(value = "/warranty/updateWarranty", method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    public int updateWarranty(@RequestBody Warranty warranty){
        return policyOpenFeginService.updateWarranty(warranty);
    }

    @RequestMapping("/warranty/updWarrantyState")
    public int updWarrantyState(String warrantyState, String warrantyId) {
        return policyOpenFeginService.updWarrantyState(warrantyState, warrantyId);
    }
    @RequestMapping(value = "/warranty/addWarranty", method = RequestMethod.POST)
    public int addWarranty(@RequestBody Warranty warranty) {
        return policyOpenFeginService.addWarranty(warranty);
    }

    @RequestMapping("/warranty/getWarrantyOne")
    public Warranty getWarrantyOne(String warrantyId) {
        return policyOpenFeginService.getWarrantyOne(warrantyId);
    }

    @RequestMapping("/warranty/getWarrantyId")
    public  PageInfo<Warranty> getWarrantyId(String warrantyId, String recognizeeName, String plateNumber, String frameId,int page) {

        return policyOpenFeginService.getWarrantyId(warrantyId, recognizeeName, plateNumber, frameId, page);
    }

    @RequestMapping("/warranty/getWarrantyAll2")
    public  List<Warranty> getWarrantyAll2(){
        List<Warranty> list=policyOpenFeginService.getWarrantyAll2();
        return list;
    }
    @RequestMapping("/warranty/getWarrantyNow")
    public String getWarrantyNow() {
        return policyOpenFeginService.getWarrantyNow();
    }

    @RequestMapping("/warranty/selectRisk")
    public List<Integer> selectRisk(String warrantyId) {
        return policyOpenFeginService.selectRisk(warrantyId);
    }

    @RequestMapping("/warranty/insertInsure")
    public int insertInsure(String warrantyId, int riskTypeId) {
        return policyOpenFeginService.insertInsure(warrantyId, riskTypeId);
    }

    @RequestMapping("/warranty/updatePremiumTotal")
    public int updatePremiumTotal(double premiumTotal, String warrantyId) {
        int count=policyOpenFeginService.updatePremiumTotal(premiumTotal, warrantyId);
        return count;
    }

    @RequestMapping("/getCaseChepai")
    List<String> getCaseChepai(String caseId){
        return policyOpenFeginService.getCaseChepai(caseId);
    }

    @RequestMapping("/warranty/getWarrantyCount")
    public int getWarrantyCount(String recognizeeId,String plateNumber) {
        return policyOpenFeginService.getWarrantyCount(recognizeeId,plateNumber);
    }
}
